<template>
    <div class="newsinfo-container">
        <h3 class="title">{{newsInfo.title}}</h3>
        <p class="subtitle">
            <span>发表时间：{{newsInfo.add_time | dateFormat}}</span>
            <span>点击：{{newsInfo.click}}次</span>
        </p>
        <hr>
        <div class="content" v-html="newsInfo.content"></div>
    <Comment :id="id"></Comment>

    </div>
</template>

<script>
import {Toast} from 'mint-ui'
import Comment from '../subcomponents/comment'
export default {
    data() {
        return {
            id: this.$route.params.id, 
            newsInfo: {}
        }
    },
    created() {
        this.getNewsInfo() 
    },
    methods: {
        getNewsInfo() {
            this.$http.get('/api/getnew/'+this.id).then(result => {
                // console.log(result)
                if (result.data.status === 0) {
                    // console.log(result.data.message[0])
                    this.newsInfo = result.data.message[0]
                }else{
                    Toast('获取新闻数据失败')
                }
            })
        }
    },
    components: {
        Comment
    }
}
</script>

<style lang="scss" scoped>
    .newsinfo-container{
        padding: 0 0.04rem;
        margin: 0;
        hr{
            margin: 0;
        }
        .title{
            font-size: 0.16rem;
            text-align: center;
            margin: 0.15rem 0;
            color: red;
        }
        .subtitle{
            font-size: 0.14rem;
            color: #226aff;
            display: flex;
            justify-content: space-between;
        }
        .content{
            font-size: 0.14rem;
        }
    }
</style>
